{include file='header'/}
<body class="pear-container">
<script type="text/html" id="add_toolbar">
    <button class="pear-btn pear-btn-warming pear-btn-md"
            data-delete="{:url('AdminLog/systemLogDel',['type'=>0])}"
            data-title="删除超过一个月" data-reload="2">
        <i class="layui-icon layui-icon-delete"></i>
        删除超过一个月
    </button>
    <button class="pear-btn pear-btn-danger pear-btn-md"
            data-delete="{:url('AdminLog/systemLogDel',['type'=>1])}"
            data-title="全部删除" data-reload="2">
        <i class="layui-icon layui-icon-delete"></i>
        全部删除
    </button>
</script>

<div class="layui-card">
    <div class="layui-card-body">
        <table id="table_list" lay-filter="table_list"></table>
    </div>
</div>

{include file='footer'/}
<script>
  layui.use(['table', 'jquery', 'drawer'], function () {
    var $ = layui.jquery;
    var table = layui.table;
    table.render({
      elem: '#table_list'
      , toolbar: '#add_toolbar'
      , defaultToolbar: [{
        layEvent: 'refresh',
        icon: 'layui-icon-refresh',
        title: '刷新'
      }, 'filter', 'exports']
      , method: 'get'
      , url: "{:url('AdminLog/systemLog')}"
      , parseData: function (res) {
        return {
          "code": 0,
          "msg": res.msg,
          "count": res.count,
          "data": res.data
        };
      }
      , cellMinWidth: 100
      , cols: [[
        {field: 'admin_id', title: 'AdminId', width: 60, align: 'center'}
        , {field: 'title', title: 'title', width: 120}
        , {field: 'url', title: '路由',minWidth:100}
        , {field: 'method', title: '方法',width:80}
        , {field: 'ip', title: 'IP地址', width: 170, align: 'center'}
        , {field: 'useragent', title: 'useragent', minWidth: 130, align: 'center'}
        , {field: 'content', title: '内容', minWidth: 170}
        , {field: 'create_time', title: '添加时间', width: 170}
      ]]
      , id: 'testReload'
      , page: true
      , limit: 10
    });
    var $ = layui.$, active = {
      reload: function () {}
    };
    //监听排序
    table.on('sort(table_list)', function (obj) {
      table.reload('testReload', {
        initSort: obj
        , where: {
          field: obj.field
          , order: obj.type
        }
      });
    });

    $('.hui-form-search .layui-btn').on('click', function () {
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
    $('.hui-form-search .reset').on('click', function () {
      window.location.reload();
    });

    //监听行工具事件
    table.on('toolbar(table_list)', function (obj) {
      if (obj.event === 'refresh') {
        table.reload('testReload');
      }
    });

  });
</script>
</body>
</html>
